
// <copyright file="DbColumnAttribute.cs" company="Subhadra Software Solutions">
//   
// </copyright>
// <summary>
//   The db column attribute.
// </summary>

namespace SubhadraSolutions.Sharp.Utils.Data.Dynamic
{
    using System;
    using System.Data;
    using System.Reflection;

    /// <summary>
    /// The db column attribute.
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
    public sealed class DbColumnAttribute : Attribute, IDbColumnMetadata
    {
        #region Constructors and Finalizers

        /// <summary>
        /// Initializes a new instance of the <see cref="DbColumnAttribute"/> class.
        /// </summary>
        /// <param name="columnName">
        /// The column name.
        /// </param>
        /// <param name="isKey">
        /// The is key.
        /// </param>
        public DbColumnAttribute(string columnName, bool isKey)
        {
            this.ColumnName = columnName;
            this.IsKey = isKey;

            // ColumnDbType = DbType.String;
            // IsNullable = true;
            // AccessType = DbColumnAccessTypes.ReadWrite;
            // TrueValueText = "Y";
            // FalseValueText = "N";
        }

        #endregion Constructors and Finalizers

        #region Public Properties

        /// <summary>
        /// Gets or sets the access type.
        /// </summary>
        public DbColumnAccessTypes AccessType { get; set; }

        /// <summary>
        /// Gets or sets the column db type.
        /// </summary>
        public DbType ColumnDbType { get; set; }

        /// <summary>
        /// Gets the column name.
        /// </summary>
        public string ColumnName { get; private set; }

        /// <summary>
        /// Gets or sets the false value text.
        /// </summary>
        public string FalseValueText { get; set; }

        /// <summary>
        /// Gets a value indicating whether is key.
        /// </summary>
        public bool IsKey { get; private set; }

        /// <summary>
        /// Gets or sets the max length.
        /// </summary>
        public int? MaxLength { get; set; }

        /// <summary>
        /// Gets a value indicating whether null-able.
        /// </summary>
        public bool IsNullable { get; set; }

        /// <summary>
        /// Gets or sets the property.
        /// </summary>
        public PropertyInfo Property { get; set; }

        /// <summary>
        /// Gets or sets the true value text.
        /// </summary>
        public string TrueValueText { get; set; }

        #endregion Public Properties
    }
}